<%--
  Created by IntelliJ IDEA.
  User: 84361
  Date: 2020/6/8
  Time: 16:40
  To change this template use File | Settings | File Templates.
--%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>角色新增</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
</head>
<body>
<%--layui-form  layui的表单样式，添加到form表单上--%>
<form class="layui-form" >

    <div class="layui-form-item">
        <label class="layui-form-label">客户</label>
        <div class="layui-input-inline">
            <select name="customer_id">
                <option value=""></option>
                <c:forEach items="${cu}" var="cu">
                    <option value="${cu.id}">${cu.name}</option>
                </c:forEach>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">成功率</label>
        <div class="layui-input-inline">
            <select name="success">
                <option value=""></option>
                <option value="10%">10%</option>
                <option value="20%">20%</option>
                <option value="30%">30%</option>
                <option value="40%">40%</option>
                <option value="50%">50%</option>
                <option value="60%">60%</option>
                <option value="70%">70%</option>
                <option value="80%">80%</option>
                <option value="90%">90%</option>
                <option value="100%">100%</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">客户联系人</label>
        <div class="layui-input-inline">
            <select name="contact_id">
                <option value=""></option>
                <c:forEach items="${li}" var="li">
                    <option value="${li.id}">${li.name}</option>
                </c:forEach>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">联系人电话</label>
        <%--layui-input-inline 行内 block 占整行--%>
        <div class="layui-input-inline">
            <input name="contact_phone" type="text"  placeholder="请输入联系人电话" autocomplete="off" class="layui-input" >
        </div>
    </div>

    <input type="hidden" name="creater" value="${sessionScope.admin.id}">

    <div class="layui-form-item">
        <label class="layui-form-label">来源</label>
        <div class="layui-input-inline">
            <select name="source">
                <option value="自己撞上来的">自己撞上来的</option>
                <option value="他人介绍">他人介绍</option>
                <option value="主动咨询">主动咨询</option>
                <option value="注册会员">注册会员</option>
                <option value="广告">广告</option>
                <option value="职员介绍">职员介绍</option>
                <option value="电子商务">电子商务</option>
                <option value="口头传达">口头传达</option>
            </select>
        </div>
    </div>

    <%--一个表单项--%>
    <div class="layui-form-item">
        <label class="layui-form-label">机会描述</label>
        <%--layui-input-inline 行内 block 占整行--%>
        <div class="layui-input-inline">
            <textarea type="text" name="description" class="layui-textarea"placeholder="请输入机会描述"></textarea>
        </div>
    </div>


    <div class="layui-form-item" >
        <%--lay-submit 标识该按钮可以提交表单--%>
        <input type="button" style="margin-left: 100px" lay-filter="add" lay-submit class="layui-btn" value="提交">
    </div>
</form>
<%--引入js--%>
<script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script>

    //layui引入特定模块的方式
    layui.use(['layer', 'form','jquery'], function () {
        var layer = layui.layer//layer 弹窗对象
            , form = layui.form;//表单对象
        var $=layui.$;

        layer.msg('Hello World');
        //表单提交监听
        form.on("submit(add)",function (data) {
            //发起异步请求，新增
            $.post("${pageContext.request.contextPath}/sales/add",data.field,function (result) {
                if(result.code==0){
                    layer.msg("新增成功")
                    //刷新父窗口的表格
                    parent.layui.table.reload("roleTable",{
                        page:{
                            curr:1
                        }
                    })
                    //关闭本窗口
                    //当你在iframe页面关闭自身时
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }else if(result.code==403){
                    window.location.href="/403.jsp";
                }
            },"json")
            return false;
        })
    });
</script>
</body>
</html>
